train <- read.csv("../../../data/train.csv")

test <- read.csv("../../../data/test.csv")

# copy the test and train data sets for EDA

train.c1 <- train
test.c1 <- test

train.c1$datetime = ymd_hms(train.c1$datetime)
test.c1$datetime = ymd_hms(test.c1$datetime)

train.c1 <- train.c1 %>%
  mutate(year = as.factor(format(datetime, format = "%Y")),
         # month = as.factor(format(datetime, format = "%m")),
         month = month(train.c1$datetime, label = TRUE, abbr = FALSE),
         day = as.factor(format(datetime, format = "%d")),
         hour = as.factor(format(datetime, format = "%H")),
         season = factor(season, labels = c("Spring", "Summer", "Fall", "Winter")),
         holiday = factor(holiday, labels = c("No", "Yes")),
         workingday = factor(workingday, labels = c("No", "Yes")),
         weather = factor(weather, labels = c("Great", "Good", "Average", "Poor")))


test.c1 <- test.c1 %>%
  mutate(year = as.factor(format(datetime, format = "%Y")),
         # month = as.factor(format(datetime, format = "%m")),
         month = month(test.c1$datetime, label = TRUE, abbr = FALSE),
         day = as.factor(format(datetime, format = "%d")),
         hour = as.factor(format(datetime, format = "%H")),
         season = factor(season, labels = c("Spring", "Summer", "Fall", "Winter")),
         holiday = factor(holiday, labels = c("No", "Yes")),
         workingday = factor(workingday, labels = c("No", "Yes")),
         weather = factor(weather, labels = c("Great", "Good", "Average", "Poor")))
Column Name Type Description
1. datetime Character YYYY-MM-DD HH24 (example: 2011-01-01 04:00:00)
2. season Integer (1-4)
3. holiday Integer (0 or 1)
4. workingday Integer (0 or 1)
5. weather Integer (1-4)
6. temp Float temparture in Celcius
7. atemp Float “feels like” temperature in Celsius
8. humidity Integer relative humidity
9. windspeed Float wind speed
10. casual Integer count of casual users
11. registered Integer count of registered users
12. count Integer count of total users (primary response variable)
train.c1 %>%
  remove_missing(na.rm = TRUE) %>%
  group_by(month) %>%
  ggplot(aes(x = month, y = count, fill=month)) +
  geom_bar(position = "dodge", stat = "summary", fun = "mean") +
  ggtitle("Bar Plot of Average Hourly Bike Rentals by Month") +
  labs(x = "Month", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  ggplot(aes(x=month, y=count, fill=month)) + 
  geom_boxplot() + 
  ggtitle("Box Plot of Bike Rentals by Month") +
  labs(x = "Month", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  remove_missing(na.rm = TRUE) %>%
  group_by(season) %>%
  ggplot(aes(x = season, y = count, fill=season)) +
  geom_bar(position = "dodge", stat = "summary", fun = "mean") +
  ggtitle("Bar Plot of Average Hourly Bike Rentals by Season") +
  labs(x = "Season", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  ggplot(aes(x=season, y=count, fill=season)) + 
  geom_boxplot() + 
  ggtitle("Box Plot of Bike Rentals by Season") +
  labs(x = "Season", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  remove_missing(na.rm = TRUE) %>%
  group_by(hour) %>%
  ggplot(aes(x = hour, y = count, fill=hour)) +
  geom_bar(position = "dodge", stat = "summary", fun = "mean") +
  ggtitle("Bar Plot of Average Bike Rentals by Hour") +
  labs(x = "Hour", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  ggplot(aes(x=hour, y=count, fill=hour)) + 
  geom_boxplot() + 
  ggtitle("Box Plot of Bike Rentals by Hour") +
  labs(x = "Hour", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  remove_missing(na.rm = TRUE) %>%
  group_by(weather) %>%
  ggplot(aes(x = weather, y = count, fill=weather)) +
  geom_bar(position = "dodge", stat = "summary", fun = "mean") +
  ggtitle("Bar Plot of Average Hourly Bike Rentals by Weather") +
  labs(x = "Weather", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  ggplot(aes(x=weather, y=count, fill=weather)) + 
  geom_boxplot() + 
  ggtitle("Box Plot of Bike Rentals by Weather") +
  labs(x = "Weather", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  remove_missing(na.rm = TRUE) %>%
  group_by(workingday) %>%
  ggplot(aes(x = workingday, y = count, fill=workingday)) +
  geom_bar(position = "dodge", stat = "summary", fun = "mean") +
  ggtitle("Bar Plot of Average Hourly Bike Rentals by Working Day") +
  labs(x = "Working Day", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  ggplot(aes(x=workingday, y=count, fill=workingday)) + 
  geom_boxplot() + 
  ggtitle("Box Plot of Bike Rentals by Working Day") +
  labs(x = "Working Day", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  remove_missing(na.rm = TRUE) %>%
  group_by(holiday) %>%
  ggplot(aes(x = holiday, y = count, fill=holiday)) +
  geom_bar(position = "dodge", stat = "summary", fun = "mean") +
  ggtitle("Bar Plot of Average Hourly Bike Rentals by Holiday") +
  labs(x = "Holiday", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1 %>%
  ggplot(aes(x=holiday, y=count, fill=holiday)) + 
  geom_boxplot() + 
  ggtitle("Box Plot of Bike Rentals by Holiday") +
  labs(x = "Holiday", y = "Average") + 
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

train.c1.numeric <- train.c1 %>%
  select_if(is.numeric)

corr <- round(cor(train.c1.numeric), 1)
  
ggcorrplot(corr, method = "circle")
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.

train.c1 %>%
  ggplot(aes(x = registered, y = count)) + 
  geom_point(alpha = 0.3) + 
  geom_smooth(method = 'lm') + 
  ggtitle("Line Chart of Counts by Registered Users") +
  labs(x = "Registered", y = "Count")
## `geom_smooth()` using formula 'y ~ x'

train.2012.june <-  train.c1 %>%
  filter(train.c1$year == 2012 & train.c1$month == "June")
ggplot(data=train.2012.june, aes(x = datetime, y = count)) +
      geom_line() + 
      ggtitle("Hourly Rental Trends for June 2012") +
      labs(x = "Time", y = "Count")

plotts.sample.wge(train.2012.june$count)

## $autplt
##  [1]  1.000000000  0.828532930  0.546215266  0.321994901  0.157437698
##  [6] -0.001661608 -0.168661853 -0.298425387 -0.336504623 -0.279103753
## [11] -0.270570795 -0.326233915 -0.362975203 -0.342110136 -0.300595184
## [16] -0.302699276 -0.331757312 -0.289079884 -0.169029889 -0.025179530
## [21]  0.111734895  0.251322989  0.429583910  0.643519434  0.767846516
## [26]  0.663108155
## 
## $freq
##   [1] 0.002192982 0.004385965 0.006578947 0.008771930 0.010964912 0.013157895
##   [7] 0.015350877 0.017543860 0.019736842 0.021929825 0.024122807 0.026315789
##  [13] 0.028508772 0.030701754 0.032894737 0.035087719 0.037280702 0.039473684
##  [19] 0.041666667 0.043859649 0.046052632 0.048245614 0.050438596 0.052631579
##  [25] 0.054824561 0.057017544 0.059210526 0.061403509 0.063596491 0.065789474
##  [31] 0.067982456 0.070175439 0.072368421 0.074561404 0.076754386 0.078947368
##  [37] 0.081140351 0.083333333 0.085526316 0.087719298 0.089912281 0.092105263
##  [43] 0.094298246 0.096491228 0.098684211 0.100877193 0.103070175 0.105263158
##  [49] 0.107456140 0.109649123 0.111842105 0.114035088 0.116228070 0.118421053
##  [55] 0.120614035 0.122807018 0.125000000 0.127192982 0.129385965 0.131578947
##  [61] 0.133771930 0.135964912 0.138157895 0.140350877 0.142543860 0.144736842
##  [67] 0.146929825 0.149122807 0.151315789 0.153508772 0.155701754 0.157894737
##  [73] 0.160087719 0.162280702 0.164473684 0.166666667 0.168859649 0.171052632
##  [79] 0.173245614 0.175438596 0.177631579 0.179824561 0.182017544 0.184210526
##  [85] 0.186403509 0.188596491 0.190789474 0.192982456 0.195175439 0.197368421
##  [91] 0.199561404 0.201754386 0.203947368 0.206140351 0.208333333 0.210526316
##  [97] 0.212719298 0.214912281 0.217105263 0.219298246 0.221491228 0.223684211
## [103] 0.225877193 0.228070175 0.230263158 0.232456140 0.234649123 0.236842105
## [109] 0.239035088 0.241228070 0.243421053 0.245614035 0.247807018 0.250000000
## [115] 0.252192982 0.254385965 0.256578947 0.258771930 0.260964912 0.263157895
## [121] 0.265350877 0.267543860 0.269736842 0.271929825 0.274122807 0.276315789
## [127] 0.278508772 0.280701754 0.282894737 0.285087719 0.287280702 0.289473684
## [133] 0.291666667 0.293859649 0.296052632 0.298245614 0.300438596 0.302631579
## [139] 0.304824561 0.307017544 0.309210526 0.311403509 0.313596491 0.315789474
## [145] 0.317982456 0.320175439 0.322368421 0.324561404 0.326754386 0.328947368
## [151] 0.331140351 0.333333333 0.335526316 0.337719298 0.339912281 0.342105263
## [157] 0.344298246 0.346491228 0.348684211 0.350877193 0.353070175 0.355263158
## [163] 0.357456140 0.359649123 0.361842105 0.364035088 0.366228070 0.368421053
## [169] 0.370614035 0.372807018 0.375000000 0.377192982 0.379385965 0.381578947
## [175] 0.383771930 0.385964912 0.388157895 0.390350877 0.392543860 0.394736842
## [181] 0.396929825 0.399122807 0.401315789 0.403508772 0.405701754 0.407894737
## [187] 0.410087719 0.412280702 0.414473684 0.416666667 0.418859649 0.421052632
## [193] 0.423245614 0.425438596 0.427631579 0.429824561 0.432017544 0.434210526
## [199] 0.436403509 0.438596491 0.440789474 0.442982456 0.445175439 0.447368421
## [205] 0.449561404 0.451754386 0.453947368 0.456140351 0.458333333 0.460526316
## [211] 0.462719298 0.464912281 0.467105263 0.469298246 0.471491228 0.473684211
## [217] 0.475877193 0.478070175 0.480263158 0.482456140 0.484649123 0.486842105
## [223] 0.489035088 0.491228070 0.493421053 0.495614035 0.497807018 0.500000000
## 
## $db
##   [1]  -4.80083688   1.73342930   2.95912507  -8.92683985  -8.69073421
##   [6]  -5.66744729   2.94645627  -3.35250420   2.11975229  -2.34448113
##  [11]  -4.79856214  -2.57332785 -12.19521424   0.77418576  -0.34262160
##  [16]   4.64444849  -6.33193241  -4.81482165  20.49417880  -5.16165867
##  [21]  -2.79857225   2.39701596 -13.25644029 -10.03861616  -2.55903082
##  [26]  -2.75691994  -3.24578552  -6.83013406 -11.03850134 -16.10784667
##  [31] -17.06518317  -6.93981202   5.88179973   1.17468825   9.74665038
##  [36]   2.58254416   0.88803320  14.04606652  -1.22326834   2.30809642
##  [41]   7.78739671  -0.95766747   2.74212477  -1.98262810 -14.20858749
##  [46] -18.15232404  -9.29856734 -13.48263068  -4.46252096 -11.83475173
##  [51]  -4.15609522  -1.85859776  -9.69423024  -2.50105261  -5.01382094
##  [56]  -5.17140433   9.17446380 -15.08544252  -9.93327318   0.62351328
##  [61]  -5.69921245  -5.58796163 -13.31053346 -21.72562613  -8.95851291
##  [66] -20.42546777 -12.23537556 -15.74587653 -15.22595232 -10.51304770
##  [71]  -9.09719326 -11.33061737  -1.60677375 -14.89905898 -14.90762213
##  [76]   5.50205224  -9.21424894  -4.09548557  -2.80172718 -10.15956755
##  [81]  -5.76756475 -10.44116910 -16.16036343 -11.63004726 -10.18053450
##  [86] -13.75559850 -10.24599621 -21.06588811  -7.38865741  -2.32618833
##  [91] -10.72133135   0.69976441  -4.68631873 -11.17618178   9.85357239
##  [96] -18.12838344  -5.56789139  -0.02963042  -6.66657705  -3.02233722
## [101] -17.01439209 -24.16596079 -13.30802867 -21.03290775 -20.00637067
## [106] -13.98763122 -17.05282259  -7.76858271 -11.56386807 -29.11448395
## [111] -11.93514820 -14.04054133 -14.34497743  -1.80896074 -11.87333489
## [116] -15.09992357 -12.62643465 -18.67758995 -19.68004587 -37.48560857
## [121] -17.81305922 -12.66202206 -19.30271343 -21.72957991 -22.55845982
## [126] -21.52415563 -20.24794907 -13.90309819  -9.72314701  -5.61385351
## [131] -19.19559151 -14.60050855   0.59948099 -18.38102178 -11.89805078
## [136]  -7.15862084 -10.36967634 -11.72153497 -15.75852898 -23.71658582
## [141] -16.81450851 -18.81539064 -16.21991566 -21.34753506 -19.89305247
## [146] -13.19212067 -14.09899848 -11.79975897  -7.67576366 -18.11440601
## [151] -12.20967807   0.30245405 -20.03790621 -22.07962076 -11.53962180
## [156] -12.43151991 -16.30598534 -25.14147098 -25.35866048 -18.42964502
## [161] -23.55702280 -28.51322067 -19.33715610 -18.72742675 -17.24528368
## [166] -39.81128192 -17.79421772 -23.42999233 -20.54481767 -18.03433446
## [171] -29.18400370 -16.56620406 -25.05958813 -26.86366360 -18.25892162
## [176] -19.95062878 -27.09251048 -16.81362766 -17.24721745 -16.28739412
## [181] -26.70932956 -23.54301604 -20.51068135 -21.86569677 -11.93944425
## [186] -16.62000644 -11.36231656 -18.63231082 -24.52936419  -4.36589597
## [191] -34.61520336 -15.91096538 -10.20266170 -23.05211137 -13.39426968
## [196] -24.33209925 -19.01332253 -22.59241833 -16.30291101 -19.64552142
## [201] -16.70147037 -16.82160791 -17.89532465 -18.40079206 -14.43032019
## [206] -13.23805791 -18.69424522 -18.47302291  -6.63751350 -26.08750074
## [211] -15.86782708 -13.99952590 -20.13650685 -17.41470506 -21.51095305
## [216] -26.42437624 -27.64556986 -24.46482622 -24.92564656 -15.52958665
## [221] -14.41204339 -27.65095248 -21.91534638 -22.41475464 -21.13152584
## [226] -21.95175792 -25.65613518 -16.69717252
## 
## $dbz
##   [1]  -0.34308511  -0.25125156  -0.05833605   0.27929749   0.79218188
##   [6]   1.47922182   2.30485524   3.21303748   4.14584144   5.05543975
##  [11]   5.90753205   6.67971713   7.35831080   7.93539606   8.40663124
##  [16]   8.76979050   9.02386426   9.16855962   9.20409523   9.13124290
##  [21]   8.95162362   8.66831954   8.28691883   7.81715134   7.27524331
##  [26]   6.68687318   6.08988071   5.53447380   5.07729130   4.76703154
##  [31]   4.62619135   4.64100032   4.76797325   4.95149532   5.13986675
##  [36]   5.29318096   5.38425539   5.39634014   5.32026212   5.15214643
##  [41]   4.89198455   4.54299904   4.11169474   3.60849581   3.04883250
##  [46]   2.45437471   1.85374214   1.28151514   0.77416165   0.36246617
##  [51]   0.06262932  -0.12933760  -0.23626124  -0.29239607  -0.33447723
##  [56]  -0.39520605  -0.50026438  -0.66787840  -0.90949582  -1.23051957
##  [61]  -1.63050787  -2.10255568  -2.63178678  -3.19322466  -3.75005016
##  [66]  -4.25448944  -4.65447399  -4.90735831  -4.99575022  -4.93499160
##  [71]  -4.76622446  -4.54063839  -4.30540157  -4.09652313  -3.93751787
##  [76]  -3.84070142  -3.80879522  -3.83582105  -3.90716419  -3.99931048
##  [81]  -4.08037668  -4.11306687  -4.06137444  -3.90023355  -3.62400906
##  [86]  -3.24863171  -2.80593011  -2.33401115  -1.86893653  -1.44025820
##  [91]  -1.07000408  -0.77358064  -0.56130747  -0.43989232  -0.41359259
##  [96]  -0.48502788  -0.65568424  -0.92615764  -1.29616336  -1.76430696
## [101]  -2.32758018  -2.98051676  -3.71393866  -4.51328543  -5.35673796
## [106]  -6.21383831  -7.04606439  -7.81132203  -8.47324413  -9.01258402
## [111]  -9.43423257  -9.76470117 -10.04164760 -10.30192303 -10.57313115
## [116] -10.86942927 -11.18990402 -11.51803313 -11.82225258 -12.05939383
## [121] -12.18343603 -12.15958008 -11.97793914 -11.65795208 -11.24035868
## [126] -10.77309935 -10.29982273  -9.85457520  -9.46133590  -9.13576984
## [131]  -8.88737401  -8.72120838  -8.63900146  -8.63965575  -8.71923220
## [136]  -8.87049228  -9.08209642  -9.33765528  -9.61505019  -9.88676467
## [141] -10.12219926 -10.29259332 -10.37779367 -10.37219021 -10.28656303
## [146] -10.14470063  -9.97684947  -9.81334275  -9.68052655  -9.59920141
## [151]  -9.58475394  -9.64805412  -9.79649944 -10.03489918 -10.36608398
## [156] -10.79120880 -11.30973334 -11.91904469 -12.61365732 -13.38391025
## [161] -14.21413395 -15.08048448 -15.94919127 -16.77687248 -17.51526828
## [166] -18.12159837 -18.57144217 -18.86643142 -19.03076919 -19.09894484
## [171] -19.10267953 -19.06291725 -18.98762087 -18.87358717 -18.71053455
## [176] -18.48632448 -18.19225295 -17.82706921 -17.39850904 -16.92206246
## [181] -16.41789369 -15.90739251 -15.41049576 -14.94417762 -14.52193691
## [186] -14.15389728 -13.84716926 -13.60624105 -13.43327228 -13.32823693
## [191] -13.28890281 -13.31066316 -13.38626766 -13.50554877 -13.65531243
## [196] -13.81964459 -13.98092530 -14.12174268 -14.22757260 -14.28959331
## [201] -14.30664053 -14.28546464 -14.23916996 -14.18452146 -14.13913217
## [206] -14.11928991 -14.13868153 -14.20788498 -14.33434393 -14.52255376
## [211] -14.77426875 -15.08862318 -15.46212383 -15.88852170 -16.35861886
## [216] -16.86012492 -17.37774411 -17.89372637 -18.38909533 -18.84559777
## [221] -19.24808254 -19.58664249 -19.85772197 -20.06371239 -20.21119143
## [226] -20.30848065 -20.36328768 -20.38092874
Acf(train.2012.june$count, lag.max = 50)

plotts.parzen.wge(train.2012.june$count)
## $freq
##   [1] 0.002192982 0.004385965 0.006578947 0.008771930 0.010964912 0.013157895
##   [7] 0.015350877 0.017543860 0.019736842 0.021929825 0.024122807 0.026315789
##  [13] 0.028508772 0.030701754 0.032894737 0.035087719 0.037280702 0.039473684
##  [19] 0.041666667 0.043859649 0.046052632 0.048245614 0.050438596 0.052631579
##  [25] 0.054824561 0.057017544 0.059210526 0.061403509 0.063596491 0.065789474
##  [31] 0.067982456 0.070175439 0.072368421 0.074561404 0.076754386 0.078947368
##  [37] 0.081140351 0.083333333 0.085526316 0.087719298 0.089912281 0.092105263
##  [43] 0.094298246 0.096491228 0.098684211 0.100877193 0.103070175 0.105263158
##  [49] 0.107456140 0.109649123 0.111842105 0.114035088 0.116228070 0.118421053
##  [55] 0.120614035 0.122807018 0.125000000 0.127192982 0.129385965 0.131578947
##  [61] 0.133771930 0.135964912 0.138157895 0.140350877 0.142543860 0.144736842
##  [67] 0.146929825 0.149122807 0.151315789 0.153508772 0.155701754 0.157894737
##  [73] 0.160087719 0.162280702 0.164473684 0.166666667 0.168859649 0.171052632
##  [79] 0.173245614 0.175438596 0.177631579 0.179824561 0.182017544 0.184210526
##  [85] 0.186403509 0.188596491 0.190789474 0.192982456 0.195175439 0.197368421
##  [91] 0.199561404 0.201754386 0.203947368 0.206140351 0.208333333 0.210526316
##  [97] 0.212719298 0.214912281 0.217105263 0.219298246 0.221491228 0.223684211
## [103] 0.225877193 0.228070175 0.230263158 0.232456140 0.234649123 0.236842105
## [109] 0.239035088 0.241228070 0.243421053 0.245614035 0.247807018 0.250000000
## [115] 0.252192982 0.254385965 0.256578947 0.258771930 0.260964912 0.263157895
## [121] 0.265350877 0.267543860 0.269736842 0.271929825 0.274122807 0.276315789
## [127] 0.278508772 0.280701754 0.282894737 0.285087719 0.287280702 0.289473684
## [133] 0.291666667 0.293859649 0.296052632 0.298245614 0.300438596 0.302631579
## [139] 0.304824561 0.307017544 0.309210526 0.311403509 0.313596491 0.315789474
## [145] 0.317982456 0.320175439 0.322368421 0.324561404 0.326754386 0.328947368
## [151] 0.331140351 0.333333333 0.335526316 0.337719298 0.339912281 0.342105263
## [157] 0.344298246 0.346491228 0.348684211 0.350877193 0.353070175 0.355263158
## [163] 0.357456140 0.359649123 0.361842105 0.364035088 0.366228070 0.368421053
## [169] 0.370614035 0.372807018 0.375000000 0.377192982 0.379385965 0.381578947
## [175] 0.383771930 0.385964912 0.388157895 0.390350877 0.392543860 0.394736842
## [181] 0.396929825 0.399122807 0.401315789 0.403508772 0.405701754 0.407894737
## [187] 0.410087719 0.412280702 0.414473684 0.416666667 0.418859649 0.421052632
## [193] 0.423245614 0.425438596 0.427631579 0.429824561 0.432017544 0.434210526
## [199] 0.436403509 0.438596491 0.440789474 0.442982456 0.445175439 0.447368421
## [205] 0.449561404 0.451754386 0.453947368 0.456140351 0.458333333 0.460526316
## [211] 0.462719298 0.464912281 0.467105263 0.469298246 0.471491228 0.473684211
## [217] 0.475877193 0.478070175 0.480263158 0.482456140 0.484649123 0.486842105
## [223] 0.489035088 0.491228070 0.493421053 0.495614035 0.497807018 0.500000000
## 
## $db
##   [1]  -4.80083688   1.73342930   2.95912507  -8.92683985  -8.69073421
##   [6]  -5.66744729   2.94645627  -3.35250420   2.11975229  -2.34448113
##  [11]  -4.79856214  -2.57332785 -12.19521424   0.77418576  -0.34262160
##  [16]   4.64444849  -6.33193241  -4.81482165  20.49417880  -5.16165867
##  [21]  -2.79857225   2.39701596 -13.25644029 -10.03861616  -2.55903082
##  [26]  -2.75691994  -3.24578552  -6.83013406 -11.03850134 -16.10784667
##  [31] -17.06518317  -6.93981202   5.88179973   1.17468825   9.74665038
##  [36]   2.58254416   0.88803320  14.04606652  -1.22326834   2.30809642
##  [41]   7.78739671  -0.95766747   2.74212477  -1.98262810 -14.20858749
##  [46] -18.15232404  -9.29856734 -13.48263068  -4.46252096 -11.83475173
##  [51]  -4.15609522  -1.85859776  -9.69423024  -2.50105261  -5.01382094
##  [56]  -5.17140433   9.17446380 -15.08544252  -9.93327318   0.62351328
##  [61]  -5.69921245  -5.58796163 -13.31053346 -21.72562613  -8.95851291
##  [66] -20.42546777 -12.23537556 -15.74587653 -15.22595232 -10.51304770
##  [71]  -9.09719326 -11.33061737  -1.60677375 -14.89905898 -14.90762213
##  [76]   5.50205224  -9.21424894  -4.09548557  -2.80172718 -10.15956755
##  [81]  -5.76756475 -10.44116910 -16.16036343 -11.63004726 -10.18053450
##  [86] -13.75559850 -10.24599621 -21.06588811  -7.38865741  -2.32618833
##  [91] -10.72133135   0.69976441  -4.68631873 -11.17618178   9.85357239
##  [96] -18.12838344  -5.56789139  -0.02963042  -6.66657705  -3.02233722
## [101] -17.01439209 -24.16596079 -13.30802867 -21.03290775 -20.00637067
## [106] -13.98763122 -17.05282259  -7.76858271 -11.56386807 -29.11448395
## [111] -11.93514820 -14.04054133 -14.34497743  -1.80896074 -11.87333489
## [116] -15.09992357 -12.62643465 -18.67758995 -19.68004587 -37.48560857
## [121] -17.81305922 -12.66202206 -19.30271343 -21.72957991 -22.55845982
## [126] -21.52415563 -20.24794907 -13.90309819  -9.72314701  -5.61385351
## [131] -19.19559151 -14.60050855   0.59948099 -18.38102178 -11.89805078
## [136]  -7.15862084 -10.36967634 -11.72153497 -15.75852898 -23.71658582
## [141] -16.81450851 -18.81539064 -16.21991566 -21.34753506 -19.89305247
## [146] -13.19212067 -14.09899848 -11.79975897  -7.67576366 -18.11440601
## [151] -12.20967807   0.30245405 -20.03790621 -22.07962076 -11.53962180
## [156] -12.43151991 -16.30598534 -25.14147098 -25.35866048 -18.42964502
## [161] -23.55702280 -28.51322067 -19.33715610 -18.72742675 -17.24528368
## [166] -39.81128192 -17.79421772 -23.42999233 -20.54481767 -18.03433446
## [171] -29.18400370 -16.56620406 -25.05958813 -26.86366360 -18.25892162
## [176] -19.95062878 -27.09251048 -16.81362766 -17.24721745 -16.28739412
## [181] -26.70932956 -23.54301604 -20.51068135 -21.86569677 -11.93944425
## [186] -16.62000644 -11.36231656 -18.63231082 -24.52936419  -4.36589597
## [191] -34.61520336 -15.91096538 -10.20266170 -23.05211137 -13.39426968
## [196] -24.33209925 -19.01332253 -22.59241833 -16.30291101 -19.64552142
## [201] -16.70147037 -16.82160791 -17.89532465 -18.40079206 -14.43032019
## [206] -13.23805791 -18.69424522 -18.47302291  -6.63751350 -26.08750074
## [211] -15.86782708 -13.99952590 -20.13650685 -17.41470506 -21.51095305
## [216] -26.42437624 -27.64556986 -24.46482622 -24.92564656 -15.52958665
## [221] -14.41204339 -27.65095248 -21.91534638 -22.41475464 -21.13152584
## [226] -21.95175792 -25.65613518 -16.69717252
## 
## $dbz
##   [1]  -0.34308511  -0.25125156  -0.05833605   0.27929749   0.79218188
##   [6]   1.47922182   2.30485524   3.21303748   4.14584144   5.05543975
##  [11]   5.90753205   6.67971713   7.35831080   7.93539606   8.40663124
##  [16]   8.76979050   9.02386426   9.16855962   9.20409523   9.13124290
##  [21]   8.95162362   8.66831954   8.28691883   7.81715134   7.27524331
##  [26]   6.68687318   6.08988071   5.53447380   5.07729130   4.76703154
##  [31]   4.62619135   4.64100032   4.76797325   4.95149532   5.13986675
##  [36]   5.29318096   5.38425539   5.39634014   5.32026212   5.15214643
##  [41]   4.89198455   4.54299904   4.11169474   3.60849581   3.04883250
##  [46]   2.45437471   1.85374214   1.28151514   0.77416165   0.36246617
##  [51]   0.06262932  -0.12933760  -0.23626124  -0.29239607  -0.33447723
##  [56]  -0.39520605  -0.50026438  -0.66787840  -0.90949582  -1.23051957
##  [61]  -1.63050787  -2.10255568  -2.63178678  -3.19322466  -3.75005016
##  [66]  -4.25448944  -4.65447399  -4.90735831  -4.99575022  -4.93499160
##  [71]  -4.76622446  -4.54063839  -4.30540157  -4.09652313  -3.93751787
##  [76]  -3.84070142  -3.80879522  -3.83582105  -3.90716419  -3.99931048
##  [81]  -4.08037668  -4.11306687  -4.06137444  -3.90023355  -3.62400906
##  [86]  -3.24863171  -2.80593011  -2.33401115  -1.86893653  -1.44025820
##  [91]  -1.07000408  -0.77358064  -0.56130747  -0.43989232  -0.41359259
##  [96]  -0.48502788  -0.65568424  -0.92615764  -1.29616336  -1.76430696
## [101]  -2.32758018  -2.98051676  -3.71393866  -4.51328543  -5.35673796
## [106]  -6.21383831  -7.04606439  -7.81132203  -8.47324413  -9.01258402
## [111]  -9.43423257  -9.76470117 -10.04164760 -10.30192303 -10.57313115
## [116] -10.86942927 -11.18990402 -11.51803313 -11.82225258 -12.05939383
## [121] -12.18343603 -12.15958008 -11.97793914 -11.65795208 -11.24035868
## [126] -10.77309935 -10.29982273  -9.85457520  -9.46133590  -9.13576984
## [131]  -8.88737401  -8.72120838  -8.63900146  -8.63965575  -8.71923220
## [136]  -8.87049228  -9.08209642  -9.33765528  -9.61505019  -9.88676467
## [141] -10.12219926 -10.29259332 -10.37779367 -10.37219021 -10.28656303
## [146] -10.14470063  -9.97684947  -9.81334275  -9.68052655  -9.59920141
## [151]  -9.58475394  -9.64805412  -9.79649944 -10.03489918 -10.36608398
## [156] -10.79120880 -11.30973334 -11.91904469 -12.61365732 -13.38391025
## [161] -14.21413395 -15.08048448 -15.94919127 -16.77687248 -17.51526828
## [166] -18.12159837 -18.57144217 -18.86643142 -19.03076919 -19.09894484
## [171] -19.10267953 -19.06291725 -18.98762087 -18.87358717 -18.71053455
## [176] -18.48632448 -18.19225295 -17.82706921 -17.39850904 -16.92206246
## [181] -16.41789369 -15.90739251 -15.41049576 -14.94417762 -14.52193691
## [186] -14.15389728 -13.84716926 -13.60624105 -13.43327228 -13.32823693
## [191] -13.28890281 -13.31066316 -13.38626766 -13.50554877 -13.65531243
## [196] -13.81964459 -13.98092530 -14.12174268 -14.22757260 -14.28959331
## [201] -14.30664053 -14.28546464 -14.23916996 -14.18452146 -14.13913217
## [206] -14.11928991 -14.13868153 -14.20788498 -14.33434393 -14.52255376
## [211] -14.77426875 -15.08862318 -15.46212383 -15.88852170 -16.35861886
## [216] -16.86012492 -17.37774411 -17.89372637 -18.38909533 -18.84559777
## [221] -19.24808254 -19.58664249 -19.85772197 -20.06371239 -20.21119143
## [226] -20.30848065 -20.36328768 -20.38092874
## 
## $dbz1
##   [1]  -0.34308511  -0.25125156  -0.05833605   0.27929749   0.79218188
##   [6]   1.47922182   2.30485524   3.21303748   4.14584144   5.05543975
##  [11]   5.90753205   6.67971713   7.35831080   7.93539606   8.40663124
##  [16]   8.76979050   9.02386426   9.16855962   9.20409523   9.13124290
##  [21]   8.95162362   8.66831954   8.28691883   7.81715134   7.27524331
##  [26]   6.68687318   6.08988071   5.53447380   5.07729130   4.76703154
##  [31]   4.62619135   4.64100032   4.76797325   4.95149532   5.13986675
##  [36]   5.29318096   5.38425539   5.39634014   5.32026212   5.15214643
##  [41]   4.89198455   4.54299904   4.11169474   3.60849581   3.04883250
##  [46]   2.45437471   1.85374214   1.28151514   0.77416165   0.36246617
##  [51]   0.06262932  -0.12933760  -0.23626124  -0.29239607  -0.33447723
##  [56]  -0.39520605  -0.50026438  -0.66787840  -0.90949582  -1.23051957
##  [61]  -1.63050787  -2.10255568  -2.63178678  -3.19322466  -3.75005016
##  [66]  -4.25448944  -4.65447399  -4.90735831  -4.99575022  -4.93499160
##  [71]  -4.76622446  -4.54063839  -4.30540157  -4.09652313  -3.93751787
##  [76]  -3.84070142  -3.80879522  -3.83582105  -3.90716419  -3.99931048
##  [81]  -4.08037668  -4.11306687  -4.06137444  -3.90023355  -3.62400906
##  [86]  -3.24863171  -2.80593011  -2.33401115  -1.86893653  -1.44025820
##  [91]  -1.07000408  -0.77358064  -0.56130747  -0.43989232  -0.41359259
##  [96]  -0.48502788  -0.65568424  -0.92615764  -1.29616336  -1.76430696
## [101]  -2.32758018  -2.98051676  -3.71393866  -4.51328543  -5.35673796
## [106]  -6.21383831  -7.04606439  -7.81132203  -8.47324413  -9.01258402
## [111]  -9.43423257  -9.76470117 -10.04164760 -10.30192303 -10.57313115
## [116] -10.86942927 -11.18990402 -11.51803313 -11.82225258 -12.05939383
## [121] -12.18343603 -12.15958008 -11.97793914 -11.65795208 -11.24035868
## [126] -10.77309935 -10.29982273  -9.85457520  -9.46133590  -9.13576984
## [131]  -8.88737401  -8.72120838  -8.63900146  -8.63965575  -8.71923220
## [136]  -8.87049228  -9.08209642  -9.33765528  -9.61505019  -9.88676467
## [141] -10.12219926 -10.29259332 -10.37779367 -10.37219021 -10.28656303
## [146] -10.14470063  -9.97684947  -9.81334275  -9.68052655  -9.59920141
## [151]  -9.58475394  -9.64805412  -9.79649944 -10.03489918 -10.36608398
## [156] -10.79120880 -11.30973334 -11.91904469 -12.61365732 -13.38391025
## [161] -14.21413395 -15.08048448 -15.94919127 -16.77687248 -17.51526828
## [166] -18.12159837 -18.57144217 -18.86643142 -19.03076919 -19.09894484
## [171] -19.10267953 -19.06291725 -18.98762087 -18.87358717 -18.71053455
## [176] -18.48632448 -18.19225295 -17.82706921 -17.39850904 -16.92206246
## [181] -16.41789369 -15.90739251 -15.41049576 -14.94417762 -14.52193691
## [186] -14.15389728 -13.84716926 -13.60624105 -13.43327228 -13.32823693
## [191] -13.28890281 -13.31066316 -13.38626766 -13.50554877 -13.65531243
## [196] -13.81964459 -13.98092530 -14.12174268 -14.22757260 -14.28959331
## [201] -14.30664053 -14.28546464 -14.23916996 -14.18452146 -14.13913217
## [206] -14.11928991 -14.13868153 -14.20788498 -14.33434393 -14.52255376
## [211] -14.77426875 -15.08862318 -15.46212383 -15.88852170 -16.35861886
## [216] -16.86012492 -17.37774411 -17.89372637 -18.38909533 -18.84559777
## [221] -19.24808254 -19.58664249 -19.85772197 -20.06371239 -20.21119143
## [226] -20.30848065 -20.36328768 -20.38092874
## 
## $dbz2
##   [1]  -0.34308511  -0.25125156  -0.05833605   0.27929749   0.79218188
##   [6]   1.47922182   2.30485524   3.21303748   4.14584144   5.05543975
##  [11]   5.90753205   6.67971713   7.35831080   7.93539606   8.40663124
##  [16]   8.76979050   9.02386426   9.16855962   9.20409523   9.13124290
##  [21]   8.95162362   8.66831954   8.28691883   7.81715134   7.27524331
##  [26]   6.68687318   6.08988071   5.53447380   5.07729130   4.76703154
##  [31]   4.62619135   4.64100032   4.76797325   4.95149532   5.13986675
##  [36]   5.29318096   5.38425539   5.39634014   5.32026212   5.15214643
##  [41]   4.89198455   4.54299904   4.11169474   3.60849581   3.04883250
##  [46]   2.45437471   1.85374214   1.28151514   0.77416165   0.36246617
##  [51]   0.06262932  -0.12933760  -0.23626124  -0.29239607  -0.33447723
##  [56]  -0.39520605  -0.50026438  -0.66787840  -0.90949582  -1.23051957
##  [61]  -1.63050787  -2.10255568  -2.63178678  -3.19322466  -3.75005016
##  [66]  -4.25448944  -4.65447399  -4.90735831  -4.99575022  -4.93499160
##  [71]  -4.76622446  -4.54063839  -4.30540157  -4.09652313  -3.93751787
##  [76]  -3.84070142  -3.80879522  -3.83582105  -3.90716419  -3.99931048
##  [81]  -4.08037668  -4.11306687  -4.06137444  -3.90023355  -3.62400906
##  [86]  -3.24863171  -2.80593011  -2.33401115  -1.86893653  -1.44025820
##  [91]  -1.07000408  -0.77358064  -0.56130747  -0.43989232  -0.41359259
##  [96]  -0.48502788  -0.65568424  -0.92615764  -1.29616336  -1.76430696
## [101]  -2.32758018  -2.98051676  -3.71393866  -4.51328543  -5.35673796
## [106]  -6.21383831  -7.04606439  -7.81132203  -8.47324413  -9.01258402
## [111]  -9.43423257  -9.76470117 -10.04164760 -10.30192303 -10.57313115
## [116] -10.86942927 -11.18990402 -11.51803313 -11.82225258 -12.05939383
## [121] -12.18343603 -12.15958008 -11.97793914 -11.65795208 -11.24035868
## [126] -10.77309935 -10.29982273  -9.85457520  -9.46133590  -9.13576984
## [131]  -8.88737401  -8.72120838  -8.63900146  -8.63965575  -8.71923220
## [136]  -8.87049228  -9.08209642  -9.33765528  -9.61505019  -9.88676467
## [141] -10.12219926 -10.29259332 -10.37779367 -10.37219021 -10.28656303
## [146] -10.14470063  -9.97684947  -9.81334275  -9.68052655  -9.59920141
## [151]  -9.58475394  -9.64805412  -9.79649944 -10.03489918 -10.36608398
## [156] -10.79120880 -11.30973334 -11.91904469 -12.61365732 -13.38391025
## [161] -14.21413395 -15.08048448 -15.94919127 -16.77687248 -17.51526828
## [166] -18.12159837 -18.57144217 -18.86643142 -19.03076919 -19.09894484
## [171] -19.10267953 -19.06291725 -18.98762087 -18.87358717 -18.71053455
## [176] -18.48632448 -18.19225295 -17.82706921 -17.39850904 -16.92206246
## [181] -16.41789369 -15.90739251 -15.41049576 -14.94417762 -14.52193691
## [186] -14.15389728 -13.84716926 -13.60624105 -13.43327228 -13.32823693
## [191] -13.28890281 -13.31066316 -13.38626766 -13.50554877 -13.65531243
## [196] -13.81964459 -13.98092530 -14.12174268 -14.22757260 -14.28959331
## [201] -14.30664053 -14.28546464 -14.23916996 -14.18452146 -14.13913217
## [206] -14.11928991 -14.13868153 -14.20788498 -14.33434393 -14.52255376
## [211] -14.77426875 -15.08862318 -15.46212383 -15.88852170 -16.35861886
## [216] -16.86012492 -17.37774411 -17.89372637 -18.38909533 -18.84559777
## [221] -19.24808254 -19.58664249 -19.85772197 -20.06371239 -20.21119143
## [226] -20.30848065 -20.36328768 -20.38092874

count.d1 = artrans.wge(train.2012.june$count, phi.tr = 1)

plotts.sample.wge(count.d1)

## $autplt
##  [1]  1.000000000  0.327893791 -0.171539952 -0.172088845 -0.014890287
##  [6]  0.029755069 -0.106796549 -0.272576678 -0.274992466  0.133282685
## [11]  0.187304506 -0.054467858 -0.168736650 -0.061550287  0.129642653
## [16]  0.086179712 -0.215608804 -0.233668505 -0.075308547  0.018255277
## [21] -0.008047202 -0.112419980 -0.106423281  0.265081883  0.674508859
## [26]  0.272600907
## 
## $freq
##   [1] 0.002197802 0.004395604 0.006593407 0.008791209 0.010989011 0.013186813
##   [7] 0.015384615 0.017582418 0.019780220 0.021978022 0.024175824 0.026373626
##  [13] 0.028571429 0.030769231 0.032967033 0.035164835 0.037362637 0.039560440
##  [19] 0.041758242 0.043956044 0.046153846 0.048351648 0.050549451 0.052747253
##  [25] 0.054945055 0.057142857 0.059340659 0.061538462 0.063736264 0.065934066
##  [31] 0.068131868 0.070329670 0.072527473 0.074725275 0.076923077 0.079120879
##  [37] 0.081318681 0.083516484 0.085714286 0.087912088 0.090109890 0.092307692
##  [43] 0.094505495 0.096703297 0.098901099 0.101098901 0.103296703 0.105494505
##  [49] 0.107692308 0.109890110 0.112087912 0.114285714 0.116483516 0.118681319
##  [55] 0.120879121 0.123076923 0.125274725 0.127472527 0.129670330 0.131868132
##  [61] 0.134065934 0.136263736 0.138461538 0.140659341 0.142857143 0.145054945
##  [67] 0.147252747 0.149450549 0.151648352 0.153846154 0.156043956 0.158241758
##  [73] 0.160439560 0.162637363 0.164835165 0.167032967 0.169230769 0.171428571
##  [79] 0.173626374 0.175824176 0.178021978 0.180219780 0.182417582 0.184615385
##  [85] 0.186813187 0.189010989 0.191208791 0.193406593 0.195604396 0.197802198
##  [91] 0.200000000 0.202197802 0.204395604 0.206593407 0.208791209 0.210989011
##  [97] 0.213186813 0.215384615 0.217582418 0.219780220 0.221978022 0.224175824
## [103] 0.226373626 0.228571429 0.230769231 0.232967033 0.235164835 0.237362637
## [109] 0.239560440 0.241758242 0.243956044 0.246153846 0.248351648 0.250549451
## [115] 0.252747253 0.254945055 0.257142857 0.259340659 0.261538462 0.263736264
## [121] 0.265934066 0.268131868 0.270329670 0.272527473 0.274725275 0.276923077
## [127] 0.279120879 0.281318681 0.283516484 0.285714286 0.287912088 0.290109890
## [133] 0.292307692 0.294505495 0.296703297 0.298901099 0.301098901 0.303296703
## [139] 0.305494505 0.307692308 0.309890110 0.312087912 0.314285714 0.316483516
## [145] 0.318681319 0.320879121 0.323076923 0.325274725 0.327472527 0.329670330
## [151] 0.331868132 0.334065934 0.336263736 0.338461538 0.340659341 0.342857143
## [157] 0.345054945 0.347252747 0.349450549 0.351648352 0.353846154 0.356043956
## [163] 0.358241758 0.360439560 0.362637363 0.364835165 0.367032967 0.369230769
## [169] 0.371428571 0.373626374 0.375824176 0.378021978 0.380219780 0.382417582
## [175] 0.384615385 0.386813187 0.389010989 0.391208791 0.393406593 0.395604396
## [181] 0.397802198 0.400000000 0.402197802 0.404395604 0.406593407 0.408791209
## [187] 0.410989011 0.413186813 0.415384615 0.417582418 0.419780220 0.421978022
## [193] 0.424175824 0.426373626 0.428571429 0.430769231 0.432967033 0.435164835
## [199] 0.437362637 0.439560440 0.441758242 0.443956044 0.446153846 0.448351648
## [205] 0.450549451 0.452747253 0.454945055 0.457142857 0.459340659 0.461538462
## [211] 0.463736264 0.465934066 0.468131868 0.470329670 0.472527473 0.474725275
## [217] 0.476923077 0.479120879 0.481318681 0.483516484 0.485714286 0.487912088
## [223] 0.490109890 0.492307692 0.494505495 0.496703297 0.498901099
## 
## $db
##   [1] -32.3367723 -25.5723506 -19.0131479 -33.0768532 -30.3409984 -24.3251385
##   [7] -13.2972974 -18.8083756 -11.4505945 -15.2285807 -15.9062064 -13.0440112
##  [13] -20.8022491  -8.2200123  -8.4392702  -2.8866783  -9.5702332  -8.5563544
##  [19]  13.4001354  -7.7623653  -8.1552272  -3.8143275 -18.3359067 -13.0142968
##  [25]  -8.2427879  -7.3224488  -7.0588825 -10.7248532 -15.7087546 -18.2689705
##  [31] -21.8357457  -5.8127905   2.6063668  -1.5620955   8.5010979  -0.1391599
##  [37]   2.0977943  13.0036261  -7.3524164   2.8689623   6.6315084  -0.5503195
##  [43]   3.9618451  -2.9628236 -17.8086304 -23.4148779  -7.9236659  -9.8649734
##  [49]  -2.1769563  -6.3424174   0.3318878  -3.3133235 -15.3244698  -1.2189806
##  [55]  -1.7963425   2.3280078  10.9518401 -19.0958650  -3.8912058   2.1009981
##  [61]  -2.4310021  -0.7448586 -15.7655129 -16.6993400  -5.7248672 -16.1068157
##  [67] -10.8320000 -12.2772210 -13.4389960  -4.6504204  -8.8962411 -11.4140398
##  [73]   3.1491173 -12.4527547  -4.6808983  10.3724827 -10.1260520   1.1935390
##  [79]   1.3677698  -2.6567317   1.8698192  -5.2339181  -6.9402906 -15.7958484
##  [85]  -3.9878923  -8.6451190  -3.9530199 -10.3589194   2.1544363  -0.1283996
##  [91] -19.3113602   6.6612707   2.9103633   6.6379131  15.5416075  -1.7031321
##  [97]   2.1802491   4.8251506   0.2295480   5.7858923  -8.7207154  -6.1756800
## [103]  -3.4183093  -6.3270509 -17.2554540  -8.9985969  -7.8626994   2.6404394
## [109] -11.1275591  -9.0939481  -9.0979020  -3.2869222   2.3741477   2.0196737
## [115]  -5.4392616  -8.5167246  -4.5576017  -7.4763231  -6.5119259  -8.5714162
## [121]  -9.3032649  -8.1633942 -16.2241705 -12.4002463 -10.4678968 -23.0231512
## [127]  -6.3942100  -8.4938339  -9.0502737   2.8063745 -14.9336759   2.0964263
## [133]   8.5143904  -4.9694573  -0.3324924  -2.4876631  -1.6855697   0.6675653
## [139]  -2.8252525  -3.6958549 -14.4258969 -11.3297101 -13.5365188 -11.8264357
## [145]  -7.0193422   1.4943761  -9.5179299 -15.6361491  -0.2726094  -6.2696802
## [151]   5.6805016   7.3794792  -6.4859411  -5.6530875  -5.9163547  -4.0017723
## [157]  -3.2157515  -7.7705516 -17.1561609  -6.5771332 -14.0778344 -18.1338858
## [163] -12.5607663  -7.5521202  -5.8525022 -14.2873385  -7.0585227  -6.0208469
## [169] -10.1294315  -4.5335597  -8.5563356 -11.5426940  -8.8747222 -12.0214577
## [175]  -2.3994945 -10.4283928  -7.9481329  -7.2438085 -14.8854991 -14.0432652
## [181] -22.4151718  -7.8442841 -18.6504431  -3.6169068 -15.1939502  -8.6052638
## [187]  -2.8819611  -3.6664756   0.3988013   2.7332175 -15.8228929  -3.9151727
## [193]  -1.2946230  -7.1547507  -1.4020267  -3.6533556 -18.8994847  -4.8433807
## [199]  -9.0864001 -10.6505926  -8.0972313  -6.2078731  -1.2692168  -9.3214436
## [205]   1.0991626 -17.4857158  -2.3791758   1.9495735  -2.3415388  -6.1674358
## [211] -35.5415711  -2.9193221  -5.7913755 -11.3105597 -22.7193544 -19.7407883
## [217] -10.0524034 -19.4853379  -5.0201761 -18.5832126  -6.3094403 -22.7397576
## [223] -15.5217280  -8.6309794 -21.4724303 -10.6914246  -9.9982721
## 
## $dbz
##   [1] -16.14422598 -15.09898543 -13.58316668 -11.82796448 -10.01720537
##   [6]  -8.26485473  -6.62982957  -5.13752236  -3.79556598  -2.60309234
##  [11]  -1.55564577  -0.64763596   0.12651406   0.77189838   1.29301976
##  [16]   1.69389502   1.97832444   2.15033766   2.21487880   2.17883784
##  [21]   2.05256605   1.85198412   1.60118879   1.33488349   1.09884018
##  [26]   0.94542098   0.92192981   1.05460585   1.33774150   1.73643692
##  [31]   2.20072503   2.68079761   3.13598663   3.53708873   3.86495816
##  [36]   4.10799464   4.25986407   4.31787814   4.28205665   4.15478976
##  [41]   3.94102810   3.64896060   3.29113209   2.88584349   2.45838686
##  [46]   2.04116502   1.67125489   1.38423718   1.20506773   1.13988378
##  [51]   1.17374610   1.27589107   1.40899717   1.53744031   1.63194359
##  [56]   1.67091174   1.63992938   1.53074340   1.34051635   1.07173324
##  [61]   0.73292345   0.34018940  -0.08079380  -0.49336165  -0.85119476
##  [66]  -1.10518715  -1.21655522  -1.17113058  -0.98539775  -0.69946763
##  [71]  -0.36246579  -0.01967458   0.29403964   0.55555703   0.75243080
##  [76]   0.88152367   0.94832262   0.96708061   0.96132274   0.96359878
##  [81]   1.01273685   1.14702844   1.39393167   1.76061140   2.23118146
##  [86]   2.77257511   3.34492669   3.91059789   4.43896452   4.90743517
##  [91]   5.30041695   5.60763761   5.82256170   5.94115824   5.96104437
##  [96]   5.88095196   5.70045924   5.41995237   5.04081316   4.56586168
## [101]   4.00011195   3.35191040   2.63448580   1.86777170   1.07995672
## [106]   0.30753149  -0.40802620  -1.02825057  -1.52877664  -1.90790487
## [111]  -2.18670375  -2.40033525  -2.58619813  -2.77459816  -2.98372582
## [116]  -3.21770303  -3.46602199  -3.70384272  -3.89419961  -3.99421595
## [121]  -3.96639457  -3.79190115  -3.47847553  -3.05747283  -2.57251770
## [126]  -2.06745068  -1.57894987  -1.13427991  -0.75209904  -0.44431140
## [131]  -0.21784064  -0.07590248  -0.01869911  -0.04357207  -0.14466860
## [136]  -0.31218685  -0.53133456  -0.78132669  -1.03509125  -1.26073689
## [141]  -1.42581991  -1.50435053  -1.48425778  -1.37142179  -1.18774169
## [146]  -0.96449207  -0.73477096  -0.52813346  -0.36821245  -0.27254285
## [151]  -0.25346904  -0.31932813  -0.47549575  -0.72513880  -1.06963807
## [156]  -1.50867399  -2.03995378  -2.65852604  -3.35560385  -4.11684417
## [161]  -4.92020074  -5.73392958  -6.51618239  -7.21850986  -7.79509895
## [166]  -8.21592175  -8.47672331  -8.59847601  -8.61650079  -8.56681346
## [171]  -8.47666124  -8.36099239  -8.22317763  -8.05794939  -7.85535073
## [176]  -7.60503642  -7.30025736  -6.94066660  -6.53322715  -6.09114051
## [181]  -5.63147115  -5.17248392  -4.73149571  -4.32356170  -3.96091863
## [186]  -3.65292978  -3.40627052  -3.22516091  -3.11152655  -3.06502439
## [191]  -3.08290871  -3.15974530  -3.28702644  -3.45281140  -3.64162327
## [196]  -3.83494712  -4.01270788  -4.15590839  -4.25007846  -4.28850171
## [201]  -4.27388086  -4.21764102  -4.13721116  -4.05250136  -3.98282218
## [206]  -3.94489314  -3.95194608  -4.01359101  -4.13606676  -4.32259427
## [211]  -4.57366817  -4.88721320  -5.25859245  -5.68049909  -6.14280707
## [216]  -6.63250922  -7.13392676  -7.62940424  -8.10064914  -8.53067931
## [221]  -8.90601567  -9.21845964  -9.46577254  -9.65094766  -9.78033842
## [226]  -9.86130274  -9.90003950
# aic5.wge(train.2012.june$count, p=0:2, q=0:2, type = "aic") # BIC picks ARMA (15,0)
# aic5.wge(train.2012.june$count, p=24:26, q=0:2, type = "aic") # BIC picks ARMA (25,1)
# aic5.wge(train.2012.june$count, p=26:30, q=0:2, type = "bic") # BIC picks ARMA (26,0)

# aic5.wge(train.2012.june$count, p=24:26, q=0:5, type = "bic") # BIC picks ARMA (26,0)
# aic5.wge(train.2012.june$count, p=24:26, q=0:2, type = "aic") # BIC picks ARMA (26,4)

# aic5.wge(train.2012.june$count, p=0:15, q=0:2, type = "aic") # AIC picks ARMA (15,1)
# aic5.wge(train.2012.june$count, p=15:25, q=0:2, type = "aic") # AIC picks ARMA (24,2)
# aic5.wge(train.2012.june$count, p=26:30, q=0:2, type = "aic") # AIC picks ARMA (30, 1)
# factor.wge(c=(rep(0,7), 1))
est.2012.june = est.arma.wge(train.2012.june$count, p=25, q=1)
## 
## Coefficients of Original polynomial:  
## 0.7955 -0.1486 -0.0433 0.0595 -0.0160 -0.0944 0.0933 -0.2967 0.3386 -0.0982 -0.1163 0.0587 -0.0345 -0.0496 0.0946 -0.1952 0.1623 -0.0468 -0.1032 0.0630 0.0025 -0.0638 0.1388 0.4465 -0.3114 
## 
## Factor                 Roots                Abs Recip    System Freq 
## 1-1.9198B+0.9869B^2    0.9726+-0.2594i      0.9934       0.0415
## 1-0.5154B+0.9856B^2    0.2615+-0.9728i      0.9928       0.2082
## 1-1.7188B+0.9833B^2    0.8740+-0.5031i      0.9916       0.0831
## 1+0.9780B+0.9746B^2   -0.5018+-0.8799i      0.9872       0.3325
## 1-1.4029B+0.9669B^2    0.7254+-0.7127i      0.9833       0.1236
## 1+0.5181B+0.9665B^2   -0.2680+-0.9812i      0.9831       0.2924
## 1-0.9603B+0.9558B^2    0.5023+-0.8910i      0.9776       0.1683
## 1+1.6958B+0.9525B^2   -0.8902+-0.5074i      0.9760       0.4175
## 1+1.8749B+0.9463B^2   -0.9906+-0.2746i      0.9728       0.4570
## 1-0.0387B+0.9225B^2    0.0210+-1.0410i      0.9605       0.2468
## 1-0.9452B              1.0580               0.9452       0.0000
## 1+0.9201B             -1.0869               0.9201       0.5000
## 1+1.3322B+0.8432B^2   -0.7900+-0.7496i      0.9182       0.3792
## 1-0.6135B              1.6299               0.6135       0.0000
##   
## 
est.2012.june$phi
##  [1]  0.795515987 -0.148554531 -0.043325557  0.059479402 -0.016004669
##  [6] -0.094380393  0.093261481 -0.296693810  0.338638046 -0.098216138
## [11] -0.116341969  0.058716888 -0.034474397 -0.049607645  0.094630835
## [16] -0.195217759  0.162268467 -0.046793836 -0.103169033  0.062992094
## [21]  0.002513806 -0.063828766  0.138763799  0.446471640 -0.311434209
est.2012.june$theta
## [1] -0.3030922
est.2012.june$avar
## [1] 5623.312
mean(train.2012.june$count)
## [1] 287.1864

\[\begin{equation} (1-0.80B+0.15B^2+0.04B^3-0.05B^4+0.02B^5+0.09B^6-0.09B^7+0.30B^8-0.34B^9+0.10B^{10}+0.12B^{11}-0.06B^{12}+0.03B^{13} + 0.05B^{14}-0.09B^{15}+0.20B^{16}-0.16B^{17}+0.05B^{18}+0.10B^{19}-0.06B^{20}-0.003B^{21}+0.06B^{22}-0.13B^{23}-0.45B^{24}+0.31B^{25})(X_t - 287.18) = (1+0.30B)a_t; \sigma^2 = 5623.31 \end{equation}\]

plotts.wge(est.2012.june$res)

# 7 day forecast

no_ahead = 24 * 7

len_of_obs = length(train.2012.june$datetime)

forecast.2012.june = fore.aruma.wge(train.2012.june$count, phi = est.2012.june$phi, theta = est.2012.june$theta, n.ahead = no_ahead, lastn = TRUE, limits = FALSE)

ase.2012.june = mean((train.2012.june$count[(len_of_obs - no_ahead + 1): len_of_obs] - forecast.2012.june$f)^2)
ase.2012.june
## [1] 29004.65
rmse.2012.june = RMSE(y_true = train.2012.june$count[(len_of_obs - no_ahead + 1): len_of_obs], y_pred = forecast.2012.june$f)
rmse.2012.june
## [1] 170.3075
predictions = round(forecast.2012.june$f)
actuals = train.2012.june$count[(len_of_obs - no_ahead + 1): len_of_obs]

preds.v.actuals.2012.june <- data.frame(predictions, actuals)    # Apply data.frame function


preds.v.actuals.2012.june <- preds.v.actuals.2012.june %>%
  mutate(diff = (round(predictions) - actuals)) %>%
  mutate(abs.diff = abs(round(predictions) - actuals))

preds.v.actuals.2012.june
##     predictions actuals diff abs.diff
## 1            21      34  -13       13
## 2             9      28  -19       19
## 3            95       4   91       91
## 4           134       8  126      126
## 5           113      10  103      103
## 6           158      40  118      118
## 7           220     194   26       26
## 8           364     505 -141      141
## 9           542     713 -171      171
## 10          335     352  -17       17
## 11          214     198   16       16
## 12          186     246  -60       60
## 13          187     334 -147      147
## 14          157     255  -98       98
## 15          145     320 -175      175
## 16          178     281 -103      103
## 17          280     392 -112      112
## 18          617     857 -240      240
## 19          630     744 -114      114
## 20          496     671 -175      175
## 21          404     448  -44       44
## 22          329     396  -67       67
## 23          269     238   31       31
## 24          169     153   16       16
## 25           80      48   32       32
## 26           43      21   22       22
## 27          139       9  130      130
## 28          192       5  187      187
## 29          176       6  170      170
## 30          203      40  163      163
## 31          249     181   68       68
## 32          365     506 -141      141
## 33          475     719 -244      244
## 34          339     357  -18       18
## 35          239     179   60       60
## 36          229     228    1        1
## 37          231     265  -34       34
## 38          199     284  -85       85
## 39          186     298 -112      112
## 40          203     324 -121      121
## 41          291     438 -147      147
## 42          547     867 -320      320
## 43          576     823 -247      247
## 44          471     579 -108      108
## 45          400     435  -35       35
## 46          348     337   11       11
## 47          296     242   54       54
## 48          209     172   37       37
## 49          118      94   24       24
## 50           71      51   20       20
## 51          157      15  142      142
## 52          219       5  214      214
## 53          209      14  195      195
## 54          223      33  190      190
## 55          260     151  109      109
## 56          352     430  -78       78
## 57          426     653 -227      227
## 58          333     366  -33       33
## 59          247     216   31       31
## 60          245     286  -41       41
## 61          253     403 -150      150
## 62          226     393 -167      167
## 63          211     376 -165      165
## 64          218     377 -159      159
## 65          295     558 -263      263
## 66          489     823 -334      334
## 67          523     693 -170      170
## 68          442     467  -25       25
## 69          388     385    3        3
## 70          353     333   20       20
## 71          309     321  -12       12
## 72          234     222   12       12
## 73          147     137   10       10
## 74           98      95    3        3
## 75          171      67  104      104
## 76          233      27  206      206
## 77          228       8  220      220
## 78          234      23  211      211
## 79          265      47  218      218
## 80          338      78  260      260
## 81          392     204  188      188
## 82          325     367  -42       42
## 83          251     435 -184      184
## 84          252     566 -314      314
## 85          265     603 -338      338
## 86          244     617 -373      373
## 87          229     573 -344      344
## 88          231     583 -352      352
## 89          295     542 -247      247
## 90          444     593 -149      149
## 91          478     571  -93       93
## 92          415     461  -46       46
## 93          374     352   22       22
## 94          353     290   63       63
## 95          316     280   36       36
## 96          251     183   68       68
## 97          172     148   24       24
## 98          125      88   37       37
## 99          184      74  110      110
## 100         241      28  213      213
## 101         239      18  221      221
## 102         242      17  225      225
## 103         268      23  245      245
## 104         328      48  280      280
## 105         368     119  249      249
## 106         319     274   45       45
## 107         255     436 -181      181
## 108         255     546 -291      291
## 109         271     615 -344      344
## 110         257     614 -357      357
## 111         242     582 -340      340
## 112         242     463 -221      221
## 113         295     580 -285      285
## 114         410     593 -183      183
## 115         441     513  -72       72
## 116         393     390    3        3
## 117         361     302   59       59
## 118         348     246  102      102
## 119         319     153  166      166
## 120         264     108  156      156
## 121         193      40  153      153
## 122         151      14  137      137
## 123         197       9  188      188
## 124         248       4  244      244
## 125         247       9  238      238
## 126         247      23  224      224
## 127         270      37  233      233
## 128         319     145  174      174
## 129         350     474 -124      124
## 130         313     250   63       63
## 131         259      91  168      168
## 132         258     121  137      137
## 133         275     168  107      107
## 134         267     225   42       42
## 135         253     219   34       34
## 136         251     237   14       14
## 137         295     332  -37       37
## 138         384     723 -339      339
## 139         412     642 -230      230
## 140         375     463  -88       88
## 141         350     362  -12       12
## 142         343     273   70       70
## 143         320     164  156      156
## 144         273      74  199      199
## 145         211      35  176      176
## 146         173      14  159      159
## 147         209      15  194      194
## 148         252       8  244      244
## 149         253      10  243      243
## 150         251      37  214      214
## 151         272     161  111      111
## 152         312     480 -168      168
## 153         337     673 -336      336
## 154         309     328  -19       19
## 155         263     180   83       83
## 156         261     230   31       31
## 157         278     292  -14       14
## 158         274     272    2        2
## 159         260     227   33       33
## 160         258     259   -1        1
## 161         294     334  -40       40
## 162         365     811 -446      446
## 163         389     795 -406      406
## 164         360     514 -154      154
## 165         339     458 -119      119
## 166         336     276   60       60
## 167         319     291   28       28
## 168         280     125  155      155
# 1 day forecast

no_ahead = 24

len_of_obs = length(train.2012.june$datetime)

forecast.2012.june = fore.aruma.wge(train.2012.june$count, phi = est.2012.june$phi, theta = est.2012.june$theta, n.ahead = no_ahead, lastn = TRUE, limits = FALSE)

ase.2012.june = mean((train.2012.june$count[(len_of_obs - no_ahead + 1): len_of_obs] - forecast.2012.june$f)^2)
ase.2012.june
## [1] 9397.58
rmse.2012.june = RMSE(y_true = train.2012.june$count[(len_of_obs - no_ahead + 1): len_of_obs], y_pred = forecast.2012.june$f)
rmse.2012.june
## [1] 96.94112
predictions = round(forecast.2012.june$f)
actuals = train.2012.june$count[(len_of_obs - no_ahead + 1): len_of_obs]

preds.v.actuals.2012.june <- data.frame(predictions, actuals)    # Apply data.frame function


preds.v.actuals.2012.june <- preds.v.actuals.2012.june %>%
  mutate(diff = (round(predictions) - actuals)) %>%
  mutate(abs.diff = abs(round(predictions) - actuals))

preds.v.actuals.2012.june
##    predictions actuals diff abs.diff
## 1            6      35  -29       29
## 2           -9      14  -23       23
## 3           98      15   83       83
## 4          114       8  106      106
## 5          105      10   95       95
## 6          125      37   88       88
## 7          148     161  -13       13
## 8          243     480 -237      237
## 9          429     673 -244      244
## 10         290     328  -38       38
## 11         189     180    9        9
## 12         218     230  -12       12
## 13         247     292  -45       45
## 14         276     272    4        4
## 15         284     227   57       57
## 16         290     259   31       31
## 17         357     334   23       23
## 18         648     811 -163      163
## 19         631     795 -164      164
## 20         476     514  -38       38
## 21         387     458  -71       71
## 22         313     276   37       37
## 23         237     291  -54       54
## 24         158     125   33       33
# series is the array of the series

# horizon is how far you want to predict into the future

# d is the order of the differencing: (1-B^)^d

# s is the order of the seasonality: (1-B^s)

# phis = order of the stationary AR term

# thetas = order of the invertible MA term

# It simply takes the given horizon and the model in the form of s,d,phis and
# thetas and figures out how many windows it can create in the data (series) and then calculates the ASE for each window.

#The output is the average off all the ASEs from each individual window.

roll.win.ase.wge = function(series, horizon = 1, s = 0, d = 0, phis = 0, thetas = 0)
{
trainingSize = length(phis) + length(thetas) + s + d + 1
numwindows = length(series)-(trainingSize + horizon) + 1
ASEHolder = numeric(numwindows)
print(paste("Please Hold For a Moment, TSWGE is processing the Rolling Window ASE with", numwindows, "windows."))
for( i in 1:numwindows)
{
invisible(capture.output(forecasts <- fore.aruma.wge(series[i:(i+(trainingSize-1))],phi = phis, theta = thetas, s = s, d = d,n.ahead = horizon)))
ASE = mean((series[(trainingSize+i):(trainingSize+ i + (horizon) - 1)] - forecasts$f)^2)
ASEHolder[i] = ASE
}
ASEHolder
hist(ASEHolder, main = "ASEs for Individual Windows")
WindowedASE = mean(ASEHolder)
print("The Summary Statistics for the Rolling Window ASE Are:")
print(summary(ASEHolder))
print(paste("The Rolling Window ASE is: ",round(WindowedASE,3)))
return(list(rwASE = WindowedASE, numwindows = numwindows, horizon = horizon, s = s, d = d, phis = phis, thetas = thetas))
}
roll.win.ase.wge(train.2012.june$count, horizon = 24*7, est.2012.june$phi, est.2012.june$theta, s = 0, d = 0)
## [1] "Please Hold For a Moment, TSWGE is processing the Rolling Window ASE with 262 windows."

## [1] "The Summary Statistics for the Rolling Window ASE Are:"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   17625   22403   27033   30053   35911   70980 
## [1] "The Rolling Window ASE is:  30052.647"
## $rwASE
## [1] 30052.65
## 
## $numwindows
## [1] 262
## 
## $horizon
## [1] 168
## 
## $s
## [1] 0
## 
## $d
## [1] 0
## 
## $phis
##  [1]  0.795515987 -0.148554531 -0.043325557  0.059479402 -0.016004669
##  [6] -0.094380393  0.093261481 -0.296693810  0.338638046 -0.098216138
## [11] -0.116341969  0.058716888 -0.034474397 -0.049607645  0.094630835
## [16] -0.195217759  0.162268467 -0.046793836 -0.103169033  0.062992094
## [21]  0.002513806 -0.063828766  0.138763799  0.446471640 -0.311434209
## 
## $thetas
## [1] -0.3030922